package com.example.hello.controller;

import com.example.hello.pojo.user;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;


    @RestController
    public class RequestController {
        //封装实体参数
        @RequestMapping("/hello")
        public String hello(user user) {
            System.out.println(user);
            return user.toString();
        }
        //封装数组参数
        @RequestMapping("/arrayparam")
            public String arrayparam(String[] hobby) {
            System.out.println(Arrays.toString(hobby));
            return "ok";
        }
        //封装list集合参数
        @RequestMapping("/listparam")
        public String listaram(@RequestParam List<Integer> hobby) {
            System.out.println(hobby);
            return "ok";
        }
        //封装date类型参数
        @RequestMapping("/dateparam")
        public String dateparam(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime date) {
            System.out.println(date);
            return "ok";
        }
        @RequestMapping("/jsonparam")
        public String jsonparam(@RequestBody user user) {
            System.out.println(user);
            return "ok";
        }
        @RequestMapping("/path/{id}/{name}")
        public String pathparam(@PathVariable("id")Integer id, @PathVariable("name")String name) {
            System.out.println(id+":"+name);
            return "ok";
        }
}
